<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Insert title here</title>
<link href="/resource/css/bootstrap.css" rel="stylesheet">
<script type="text/javascript" src="/resource/js/jquery-3.2.1.js"></script>
<script type="text/javascript" src="/resource/js/bootstrap.js"></script>
<script type="text/javascript">
$(function(){
	$.get("/getCategorys",function(categorys){
		for(var i in categorys){
		 $("#cat").append("<option value='"+categorys[i].id+"'>"+categorys[i].name+"</option>")	
		}
	})
	
	
	
})

//执行添加
function add(){
	$.post("/add",$("form").serialize(),function(flag){
		if(flag){
			alert("增加成功");
			location.href="/list";
		}else{
			alert("增加失败")
		}
		
	})
	
}
</script>
 
</head>
<body>
	<form action="">
		植物名称：<input type="text" name="name"><br>
		 植物 描述：<input	type="text" name="mx"><br> 
		植物分类：<select id="cat" name="cid">
		
		
		</select>
		
		<br> 
		创建时间：<input type="date" name="created"><br>
     <button type="button" onclick="add()">增加</button>

	</form>
</body>
</html>